package com.demo.io;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * @author wangning
 * @date 2023/12/15 17:54
 * @description 获取文件的Content Type
 * 通过probeContentType(Path path)方法获取文件的MIME类型
 */
public class GetFileContentType {
    public static void main(String[] args) throws Exception {
        File file = new File("E:\\my-project\\workspace\\java-demo\\io\\src\\main\\resources\\file\\test.txt");
        Path path = file.toPath();
        String contentType = Files.probeContentType(path);
        System.out.println("Content Type: " + contentType);

    }
}
